<!DOCTYPE html>
<html>
<head>
  <title>设备信息表添加</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="bootstrap4/css/bootstrap.min.css">
  <link rel="stylesheet" href="css2/style2.css"> 
  <script src="http://static.runoob.com/assets/jquery-validation-1.14.0/lib/jquery.js"></script>
  <script src="http://static.runoob.com/assets/jquery-validation-1.14.0/dist/jquery.validate.min.js"></script>
  <script src="js2/my.js"></script>
</head>

<script type="text/javascript">
$(function(){
	$("#formID").validate({
        rules: {
            "equmtName": {
                required: true
            },
            "equmtIp": {
                required: true
            },
            "orgId": {
                required: true
            },
            "fixCycle": {
                required: true
            },
            "equmtStatue": {
                required: true
            },
            "equpicPath": {
                required: true
            },
            "equmtOverload": {
                required: true
            },
            "equmtDiva": {
                required: true
            },
            "equmtDivb": {
                required: true
            },
            "equmtDivc": {
                required: true
            },
            "equmtDivd": {
                required: true
            },
            "equmtDive": {
                required: true
            },
            "equmtLon": {
                required: true
            },
            "equmtLat": {
                required: true
            },
            "takecareStdate": {
                required: true
            },
            "takecareCudate": {
                required: true
            }
        },
        messages:{
            "equmtName": {
                required: "设备名称不能为空"
            },
            "equmtIp": {
                required: "设备IP不能为空"
            },
            "orgId": {
                required: "机构id不能为空"
            },
            "fixCycle": {
                required: "维护周期(月)不能为空"
            },
            "equmtStatue": {
                required: "设备状态不能为空"
            },
            "equpicPath": {
                required: "设备照片不能为空"
            },
            "equmtOverload": {
                required: "超载重量不能为空"
            },
            "equmtDiva": {
                required: "分度值不能为空"
            },
            "equmtDivb": {
                required: "跟踪不能为空"
            },
            "equmtDivc": {
                required: "通信不能为空"
            },
            "equmtDivd": {
                required: "传感器不能为空"
            },
            "equmtDive": {
                required: "波特率不能为空"
            },
            "equmtLon": {
                required: "经度不能为空"
            },
            "equmtLat": {
                required: "纬度不能为空"
            },
            "takecareStdate": {
                required: "安装时间不能为空"
            },
            "takecareCudate": {
                required: "最新维护时间不能为空"
            }
        },
        submitHandler:function(form){
        	$.ajax({
        		type: "POST",//方法类型
                dataType: "json",//预期服务器返回的数据类型
                url: "saveEqumtInfo" ,//url
                data: $('#formID').serialize(),
                success: function (result) {
                    console.log(result);//打印服务端返回的数据(调试用)
                    if (result.code == 200) {
                        if(confirm(result.msg+'是否继续？？'))
                        {   
                        	 window.location.href = "addEqumtInfo";
                        }
                        else
                        {  
                        	 window.location.href = "queryForEqumtInfoList";
                        }
                    }
                    else{                	
                    	alert(result.msg);
                    }
                     
                },
                error : function() {
                    alert("异常！");
                }
            });
        },
        //自定义错误样式
        errorClass:"text-danger",
        //未通过验证,进行高亮处理或其他处理；
        highlight:function(input){
            $(input).closest(".form-group").addClass("has-error");
        },
        //通过验证,清除高亮效果或其他处理；
        unhighlight:function(input){
            $(input).closest(".form-group").removeClass("has-error");
        }
	});
});

</script>
<body>
<div class="header-area" id="headerArea">
   <div class="container h-100 d-flex align-items-center justify-content-between">
 
     <div class="logo-wrapper">
     <a th:href="@{/queryForEqumtInfoList}"> 返回 </a>
	 </div>
     <!-- Search Form-->
     <div class="top-search-form">
      	 设备信息表添加
     </div>
     <div  id="suhaNavbarToggler"><span></span><span></span><span></span></div>
   </div>
 </div>

<div class="container mt60">
  <form id="formID"  >
  	<input type="hidden" name="equmtInfoId" th:value="${equmtInfoVO?.equmtInfoId}" /> 
    <div class="form-group">
       <div class="single-payment-method"> 
       		<img class="mb-3" src="img/bg-img/9.jpeg"   width="100%"alt="">
       </div>
    </div>
    <div class="form-group"> 
      <label class="title fl"></label>
      <label for="equmtName" class="fl" >设备名称:</label>
      <input type="text" class="form-control" id="equmtName" placeholder="请填写设备名称" 
      name="equmtName"
      th:value="${equmtInfoVO?.equmtName}" >
    </div>
    <div class="form-group"> 
      <label class="title fl"></label>
      <label for="equmtIp" class="fl" >设备IP:</label>
      <input type="text" class="form-control" id="equmtIp" placeholder="请填写设备IP" 
      name="equmtIp"
      th:value="${equmtInfoVO?.equmtIp}" >
    </div>
    <div class="form-group"> 
      <label class="title fl"></label>
      <label for="orgId" class="fl" >机构id:</label>
      <input type="text" class="form-control" id="orgId" placeholder="请填写机构id" 
      name="orgId"
      th:value="${equmtInfoVO?.orgId}" >
    </div>
    <div class="form-group"> 
      <label class="title fl"></label>
      <label for="fixCycle" class="fl" >维护周期(月):</label>
      <input type="text" class="form-control" id="fixCycle" placeholder="请填写维护周期(月)" 
      name="fixCycle"
      th:value="${equmtInfoVO?.fixCycle}" >
    </div>
    <div class="form-group"> 
      <label class="title fl"></label>
      <label for="equmtStatue" class="fl" >设备状态:</label>
      <input type="text" class="form-control" id="equmtStatue" placeholder="请填写设备状态" 
      name="equmtStatue"
      th:value="${equmtInfoVO?.equmtStatue}" >
    </div>
    <div class="form-group"> 
      <label class="title fl"></label>
      <label for="equpicPath" class="fl" >设备照片:</label>
      <input type="text" class="form-control" id="equpicPath" placeholder="请填写设备照片" 
      name="equpicPath"
      th:value="${equmtInfoVO?.equpicPath}" >
    </div>
    <div class="form-group"> 
      <label class="title fl"></label>
      <label for="equmtOverload" class="fl" >超载重量:</label>
      <input type="text" class="form-control" id="equmtOverload" placeholder="请填写超载重量" 
      name="equmtOverload"
      th:value="${equmtInfoVO?.equmtOverload}" >
    </div>
    <div class="form-group"> 
      <label class="title fl"></label>
      <label for="equmtDiva" class="fl" >分度值:</label>
      <input type="text" class="form-control" id="equmtDiva" placeholder="请填写分度值" 
      name="equmtDiva"
      th:value="${equmtInfoVO?.equmtDiva}" >
    </div>
    <div class="form-group"> 
      <label class="title fl"></label>
      <label for="equmtDivb" class="fl" >跟踪:</label>
      <input type="text" class="form-control" id="equmtDivb" placeholder="请填写跟踪" 
      name="equmtDivb"
      th:value="${equmtInfoVO?.equmtDivb}" >
    </div>
    <div class="form-group"> 
      <label class="title fl"></label>
      <label for="equmtDivc" class="fl" >通信:</label>
      <input type="text" class="form-control" id="equmtDivc" placeholder="请填写通信" 
      name="equmtDivc"
      th:value="${equmtInfoVO?.equmtDivc}" >
    </div>
    <div class="form-group"> 
      <label class="title fl"></label>
      <label for="equmtDivd" class="fl" >传感器:</label>
      <input type="text" class="form-control" id="equmtDivd" placeholder="请填写传感器" 
      name="equmtDivd"
      th:value="${equmtInfoVO?.equmtDivd}" >
    </div>
    <div class="form-group"> 
      <label class="title fl"></label>
      <label for="equmtDive" class="fl" >波特率:</label>
      <input type="text" class="form-control" id="equmtDive" placeholder="请填写波特率" 
      name="equmtDive"
      th:value="${equmtInfoVO?.equmtDive}" >
    </div>
    <div class="form-group"> 
      <label class="title fl"></label>
      <label for="equmtLon" class="fl" >经度:</label>
      <input type="text" class="form-control" id="equmtLon" placeholder="请填写经度" 
      name="equmtLon"
      th:value="${equmtInfoVO?.equmtLon}" >
    </div>
    <div class="form-group"> 
      <label class="title fl"></label>
      <label for="equmtLat" class="fl" >纬度:</label>
      <input type="text" class="form-control" id="equmtLat" placeholder="请填写纬度" 
      name="equmtLat"
      th:value="${equmtInfoVO?.equmtLat}" >
    </div>
    <div class="form-group"> 
      <label class="title fl"></label>
      <label for="takecareStdate" class="fl" >安装时间:</label>
      <input type="text" class="form-control" id="takecareStdate" placeholder="请填写安装时间" 
      name="takecareStdate"
      th:value="${equmtInfoVO?.takecareStdate}" >
    </div>
    <div class="form-group"> 
      <label class="title fl"></label>
      <label for="takecareCudate" class="fl" >最新维护时间:</label>
      <input type="text" class="form-control" id="takecareCudate" placeholder="请填写最新维护时间" 
      name="takecareCudate"
      th:value="${equmtInfoVO?.takecareCudate}" >
    </div>
     <button type="submit" class="btn btn-primary btn-block" >提交</button>
  </form>
 
</div>

</body>
</html>
